package com.atguigu.vip.spring.framework.beans;


import com.atguigu.vip.spring.framework.core.GPFactoryBean;

/**
 *  以后AOP就有用
 */
public class BeanWrapper implements GPFactoryBean {

    //还会用到 观察者模式，
    //1、支持事件响应，会有一个监听
    private BeanPostProcessor postProcessor;

    private  Object wrapperInstance; //被包装过的instance
    //原生的通过反射new出来的，要把它包装起来，存下来
    private  Object originalInstance;

    public BeanWrapper(Object instance){
        this.wrapperInstance = instance;
        this.originalInstance = instance;  //没有AOP的时候，暂时把这两个对象赋成一样的
    }

    public Object getWrappedInstance(){
        return this.wrapperInstance;
    }

    /**
     * 返回代理以后的class
     *   JDK的动态代理之后，可能会得到 $Proxy00类的东西
     */
    public Class<?> getWrappedClass(){
        return this.wrapperInstance.getClass();
    }


    public BeanPostProcessor getPostProcessor() {
        return postProcessor;
    }

    public void setPostProcessor(BeanPostProcessor postProcessor) {
        this.postProcessor = postProcessor;
    }
}
